package cn.edu.scnu.semart.echats.controller;

import cn.edu.scnu.semart.common.result.Result;
import cn.edu.scnu.semart.echats.service.UserStatService;
import cn.edu.scnu.semart.vo.user.*;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/stat/user")
@RequiredArgsConstructor
public class UserStatController {

    private final UserStatService userStatService;

    // 返回 [{date:'2025-07-23',cumulative:2}, ...]
    @GetMapping("/trend/daily")
    public Result<List<UserTrendVO>> dailyTrend() {
        return Result.ok(userStatService.dailyCumulative());
    }

    // 用户类型占比
    @GetMapping("/type-ratio")
    public Result<List<UserTypeRatioVO>> typeRatio() {
        return Result.ok(userStatService.typeRatio());
    }

    //封禁-正常占比
    @GetMapping("/status-ratio")
    public Result<List<UserStatusRatioVO>> statusRatio() {
        return Result.ok(userStatService.statusRatio());
    }

    // 每日新增关注数趋势
    @GetMapping("/follow-daily")
    public Result<List<FollowDailyVO>> followTrend() {
        return Result.ok(userStatService.followDaily());
    }

    @GetMapping("/graph")
    public Result<GraphVO> graph() {
        return Result.ok(userStatService.graphData());
    }
}